package com.dz.finance.api.controller;

import com.dz.finance.biz.dto.CreateMenuDTO;
import com.dz.finance.biz.service.SysMenuService;
import com.dz.finance.biz.vo.ListTreeMenuVo;
import com.dz.finance.common.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: DengHaoQi
 * @date: 2024/7/1 15:35
 * @description: 系统菜单模块
 */

@Slf4j
@Api(tags = "系统菜单管理")
@RestController
@RequestMapping("/sysMenu")
@RequiredArgsConstructor
public class SysMenuController {

    private final SysMenuService sysMenuService;


    @ApiOperation("新增菜单")
    @PostMapping("/create")
    public Result<Boolean> create(@Validated @RequestBody CreateMenuDTO dto) {
        boolean b = sysMenuService.create(dto);
        return Result.ok(b);
    }


    @ApiOperation("树形菜单列表")
    @GetMapping("/listTreeMenu")
    public Result<List<ListTreeMenuVo>> listTreeMenu(@RequestParam(required = false) String title) {
        List<ListTreeMenuVo> treeMenuVoList = sysMenuService.getTreeMenuList(title);
        return Result.ok(treeMenuVoList);
    }

}
